package com.lc.rongzecaifu.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.lc.rongzecaifu.MyApplication;
import com.lc.rongzecaifu.conn.JsonIndex;
import com.lc.rongzecaifu.rongzecaifu.R;
import com.zcx.helper.bound.BoundViewHelper;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/12/12.
 */
public class IconListRecyAdapter extends RecyclerView.Adapter<IconListRecyAdapter.ViewHolder> {

    private Context context;
    private List<JsonIndex.Info.Linek_img> list;


    public IconListRecyAdapter(Context context, List<JsonIndex.Info.Linek_img> list) {
        this.context = context;
        this.list = list;
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        // each data item is just a string in this case
        @Bind(R.id.mine_head_iv)
        ImageView mine_head_iv;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

    @Override
    public IconListRecyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = BoundViewHelper.boundView(this, MyApplication.scaleScreenHelper.loadView((ViewGroup) LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_grid_item, null)));
        // set the view's size, margins, paddings and layout parameters
        IconListRecyAdapter.ViewHolder vh = new IconListRecyAdapter.ViewHolder(view);


        return vh;
    }

    @Override
    public void onBindViewHolder(IconListRecyAdapter.ViewHolder holder, int position) {
    //    holder.mine_head_iv.setImageURI(Uri.parse(list.get(position).link_img));

        Glide.with(context)
                .load(list.get(position).link_img)
                .into(holder.mine_head_iv);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
